Skip to content

Conversation

@reese
Copy link
Collaborator

@reese reese commented Jan 10, 2026

Currently for mod conditionals (like return if foo), we transform those to multiple lines (if foo \n return \n end) if they're multiline/too long. The current implementation does this in a wildly inefficient manner: cloning the ~entire parser state, rendering the whole thing as a string, and then checking if the string is multiline. It does all this every time a mod conditional comes up, so it currently takes up a pretty decent chunk of profiling, not to mention it's kinda a hack.

This PR makes conditionals work like any other breakable. It stashes the tokens for the predicate and the body of the conditional, then uses those to render into either an inline or block form depending on the line length. This should more accurate and efficient (with much less cloning/allocating) than rendering every single time.

@reese reese force-pushed the reese-conditional-breakables branch from de4cc64 to 7f0d3c3 Compare January 10, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants